package casa.depesos.app.com.dlg;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import casa.depesos.app.com.databinding.DlgDetailBinding;
import casa.depesos.app.com.http.data.Pay;
import casa.depesos.app.com.utils.Utils;

public class DetailDlg extends FullScreenDlg {

    DlgDetailBinding binding;
    int type;
    Pay info;

    public DetailDlg setParam(int type, Pay info) {
        this.type = type;
        this.info = info;
        return this;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DlgDetailBinding.inflate(inflater, container, false);
        if (type == 0) {
            binding.title.setText("Detalles del préstamo");
            binding.tv.setText("Monto acreditado");
            binding.amount.setText(Utils.formatNoFloat(info.recv + "", true));
            binding.fee.setText(Utils.formatNoFloat(info.pre + "", true));
            binding.vat.setText(Utils.formatNoFloat(info.preVat + "", true));
        } else {
            binding.title.setText("Detalles del pago");
            binding.tv.setText("Monto de pago");
            binding.amount.setText(Utils.formatNoFloat(info.repay + "", true));
            binding.fee.setText(Utils.formatNoFloat(info.post + "", true));
            binding.vat.setText(Utils.formatNoFloat(info.postVat + "", true));
        }
        binding.borrow.setText(Utils.formatNoFloat(info.contract + "", true));
        binding.ok.setOnClickListener(v -> dismiss());

        return binding.getRoot();
    }
}
